"""
@Time ： 2024/4/27 22:15
@Auth ： czm
@File ：DepartmentPage.py
@IDE ：PyCharm
"""
from common.base import Base


class DeptManagement(Base):
    # 页面元素定位
    basic_info_location = ('xpath', '//*[text()="企业综合管理"]')  # xpath定位企业综合管理
    dept_location = ('xpath', '//*[text()="部门管理"]')  # xpath定位部门管理
    add_dept_location = ('xpath', '//*[text()="添加组织"]')  # xpath定位添加组织
    input_organization_location = ('css selector', '#form_item_name')  # css定位组织名称输入框
    select_dept_location = ('xpath', '//*[text()="市场部"]')  # xpath定位
    send_button_location = ('xpath', '//*[@class="ant-modal-footer"]/button[2]')  # xpath定位确定按钮
    cancel_button_location = ('xpath', '//*[text()="取 消"]')  # xpath定位取消按钮
    dept_name_location = ('xpath', '//*[text()="综合办公室"]')
    err_message_location = ('css selector', '.ant-form-item-explain-error')

    def click_basic_info(self):
        # 点击企业综合管理菜单
        self.click(self.basic_info_location)

    def click_dept(self):
        # 点击部门管理菜单
        self.click(self.dept_location)

    def add_dept_button_click(self):
        # 点击添加组织按钮
        self.click(self.add_dept_location)

    def input_dept_name(self, text):
        # 输入组织名称
        self.send(self.input_organization_location, text)

    def click_send_button(self):
        # 点击确定按钮
        self.click(self.send_button_location)

    def click_cancel_button(self):
        # 点击取消按钮
        self.click(self.cancel_button_location)

    def get_deptname_text(self):
        # 获取部门名称text属性
        deptname = self.get_text(self.dept_name_location)
        return deptname

    def get_null_deptname_err(self):
        # 获取部门为空的错误信息
        null_deptname = self.get_text(self.err_message_location)

        return null_deptname
